package com.punch.system.controller;


import com.punch.common.dto.system.TopTeacherDTO;
import com.punch.common.model.Result;
import com.punch.common.page.PageInfo;
import com.punch.common.query.syste.TopTeacherQueryInfo;
import com.punch.common.vo.common.OptionVO;
import com.punch.common.vo.system.TopTeacherVO;
import com.punch.system.service.TopTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 名师表 前端控制器
 * </p>
 *
 * @author wjj
 * @since 2020-12-14
 */
@RestController
@Api(value = "TopTeacherController", tags = "名师管理Controller")
public class TopTeacherController {


    @Resource
    private TopTeacherService topTeacherService;

    /**
     * 名师列表
     *
     * @param queryInfo 查询条件
     * @return PageInfo<TopTeacherVO>
     */
    @GetMapping(value = "/top-teachers", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "名师列表", notes = "名师列表", produces = "application/json")
    public Result<PageInfo<TopTeacherVO>> listTopTeacher(@ModelAttribute TopTeacherQueryInfo queryInfo) {
        return Result.succeed(topTeacherService.listTopTeacher(queryInfo));
    }


    /**
     * 保存名师
     *
     * @param topTeacherDTO 提交表单
     * @return id
     */
    @PostMapping(value = "/top-teacher", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 保存名师", notes = " 保存名师", produces = "application/json")
    public Result<Integer> saveTopTeacher(@RequestBody TopTeacherDTO topTeacherDTO) {
        return Result.succeed(topTeacherService.saveTopTeacher(topTeacherDTO));
    }

    /**
     * 修改名师
     *
     * @param topTeacherDTO 提交表单
     * @return id
     */
    @PutMapping(value = "/top-teacher", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改名师", notes = " 修改名师", produces = "application/json")
    public Result<Integer> updateTopTeacher(@RequestBody TopTeacherDTO topTeacherDTO) {
        return Result.succeed(topTeacherService.updateTopTeacher(topTeacherDTO));
    }


    /**
     * 名师详情
     *
     * @param teacherId teacherId
     * @return TopTeacherVO
     */
    @GetMapping(value = "/top-teacher/{teacherId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "名师详情", notes = "名师详情", produces = "application/json")
    public Result<TopTeacherVO> getTopTeacher(@PathVariable Integer teacherId) {
        return Result.succeed(topTeacherService.getTopTeacher(teacherId));
    }

    /**
     * 删除名师
     *
     * @param teacherId teacherId
     * @return id
     */
    @DeleteMapping(value = "/top-teacher/{teacherId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 删除名师", notes = " 删除名师", produces = "application/json")
    public Result<Integer> deleteTopTeacher(@PathVariable Integer teacherId) {
        return Result.succeed(topTeacherService.deleteTopTeacher(teacherId));
    }


    /**
     * 修改名师状态
     *
     * @param teacherId teacherId
     * @param status    状态 0-不显示 1-显示
     * @return teacherId
     */
    @PutMapping(value = "/top-teacher/{teacherId}/status/{status}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改名师状态", notes = " 修改名师状态", produces = "application/json")
    public Result<Integer> updateTopTeacherStatus(@PathVariable Integer teacherId, @PathVariable Integer status) {
        return Result.succeed(topTeacherService.updateTopTeacherStatus(teacherId, status));
    }

    /**
     * 简单名师列表
     *
     * @return List<OptionVO < Integer>>
     */
    @GetMapping(value = "/top-teachers/simple", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "简单名师列表", notes = "简单名师列表", produces = "application/json")
    public Result<List<OptionVO<Integer>>> listSimpleTeacher() {
        return Result.succeed(topTeacherService.listSimpleTeacher());
    }
}
